import 'lib-flexible/flexible';
import './resources/css/basic.scss';
import Vue from 'vue';
import App from './App.vue';
import { router } from './router';
import Request from './components/Request';
import { Lazyload } from 'vant';
import VueClipboard from 'vue-clipboard2';

// console.log(router);
Vue.prototype.$http = Request;
Vue.prototype.HOST = '/api';
Vue.directive('preventReClick', {
  inserted(el, binding) {
    el.addEventListener('click', () => {
      if (!el.disabled) {
        el.disabled = true;
        setTimeout(() => {
          el.disabled = false;
        }, binding.value || 2000);
      }
    });
  }
});

Vue.use(VueClipboard);
Vue.use(Lazyload, {
  loading: 'http://img.580travel.com/image/bocmm/imageloading.jpg',
  error: 'http://img.580travel.com/image/bocmm/imageloadfaild.jpg'
});

// 挂载路由
new Vue({
  router,
  el: '#app',
  render: h => h(App),
  beforeDestroy() {
    document.querySelector('body').removeAttribute('style');
  }
});
